package com.dpj.servlet;

import com.dpj.service.UserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
//1
@WebServlet("/checkNameServlet")
public class CheckNameServlet extends HttpServlet {
    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置响应数据的中文乱码
        response.setContentType("text/html;charset=utf-8");
        // 设置请求参数的中文乱码
        request.setCharacterEncoding("utf-8");
        String username = request.getParameter("username");
        System.out.println(username);
        Boolean flag=userService.selectByName(username);
        System.out.println(flag);
        response.getWriter().print("ok");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
